import React from "react";
import { Button, Result } from "antd";
import { useNavigate } from "react-router";
import { ResultStatusType } from "antd/es/result";

const ResultCom: React.FC<{ status: ResultStatusType; title: string; subTitle?: string }> = (props) => {
  const { status, title, subTitle } = props;
  const history = useNavigate();
  return (
    <Result
      status={status}
      title={title}
      subTitle={subTitle || "页面不存在"}
      extra={
        <Button
          type="primary"
          onClick={() => {
            history({ pathname: "/" }, { replace: true });
          }}
        >
          返回首页
        </Button>
      }
    />
  );
};

export default ResultCom;
